package com.heima.wemedia.controller;

import com.heima.model.wemedia.dtos.WmSensitiveDto;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.service.WmSensitiveService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


@RestController
@RequestMapping("/api/v1/sensitive")
@Api(tags = "敏感词管理")
public class WmSensitiveController {
    @Autowired
    private WmSensitiveService sensitiveService;

    @DeleteMapping("/del/{id}")
    @ApiOperation("删除敏感词")
    public ResponseResult deleteById(@PathVariable Integer id){
        return sensitiveService.deleteById(id);
    }

    @PostMapping("/list")
    @ApiOperation("分页查询敏感词")
    public ResponseResult findAll(@RequestBody WmSensitiveDto dto){
        return sensitiveService.findAll(dto);
    }

    @PostMapping("/save")
    @ApiOperation("保存敏感词")
    public ResponseResult saveSensitive(@RequestBody WmSensitive sensitive){
        return sensitiveService.saveSensitive(sensitive);
    }
    @PostMapping("/update")
    @ApiOperation("更新敏感词")
    public ResponseResult updateSensitive(@RequestBody WmSensitive sensitive) {
        return sensitiveService.updateSensitive(sensitive);
    }

    @PostMapping("/export")
    @ApiOperation("导出敏感词Excel")
    public void export(){
        sensitiveService.export();
    }

    @PostMapping("/import")
    @ApiOperation("导入敏感词Excel")
    public void importExcel(@RequestParam("file") MultipartFile file) {
        sensitiveService.importExcel(file);
    }
}
